<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<!--User: xulf Date: 2018/7/16 Time: 19:23-->
<link th:href="@{/css/labelColor.css}" rel="stylesheet">
<body>
<form id="processAidsForm" role="form" method="post" action="acce/insert">
    <div class="form-group">
        <label for="pMaterielCode">物料号<span>*</span></label>
        <input class="form-control" id="pMaterielCode" name="pMaterielCode" type="text"

               placeholder="请输入物料号"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pMaterielName">物料名称<span>*</span></label>
        <input class="form-control" id="pMaterielName" name="pMaterielName" type="text"

               placeholder="请输入物料名称"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pTechnicalConditions">技术条件/牌号规格</label>
        <input class="form-control" id="pTechnicalConditions" name="pTechnicalConditions" type="text"

               placeholder="请输入技术条件/牌号规格"/><!--th:value="${entity.level}"-->
    </div>
    <!--<div class="form-group">-->
        <!--<label for="pUnit">单位</label>-->
        <!--<select class="form-control" name="pUnit" id="pUnit" placeholder="请选择单位">-->
            <!--<option></option>-->
            <!--<option>EA</option> &lt;!&ndash;th:selected="${data.getResource()=='MAKE'?true:false}"&ndash;&gt;-->
            <!--<option>Kg</option>-->
            <!--<option>L</option>-->
            <!--<option>mm</option>-->
        <!--</select>-->
    <!--</div>-->
    <div class="form-group">
        <label for="pMeasuringUnit">计量单位</label>
        <input class="form-control" id="pMeasuringUnit" name="pMeasuringUnit" type="text"

               placeholder="请输入计量单位"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pMaterielPurpose">材料用途</label>
        <input class="form-control" id="pMaterielPurpose" name="pMaterielPurpose" type="text"

               placeholder="请输入材料用途"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pDosageBicycle">单车用量</label>
        <input class="form-control" id="pDosageBicycle" name="pDosageBicycle" type="text"

               placeholder="请输入单车用量"/><!--th:value="${entity.level}"-->
    </div>
    <div class="form-group">
        <label for="pNote">备注</label>
        <input class="form-control" id="pNote" name="pNote" type="text"

               placeholder="请输入备注"/><!--th:value="${entity.level}"-->
    </div>
</form>

<script th:inline="javascript">
    <![CDATA[
    $(function () {
        $('#processAidsForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                pMaterielCode: {
                    message: '物料号验证失败',
                    validators: {
                        notEmpty: {
                            message: '物料号不能为空'
                        }
                    }
                },
                pMaterielName: {
                    message: '材料名称验证失败',
                    validators: {
                        notEmpty: {
                            message: '材料名称不能为空'
                        }
                    }
                },
            }
        });
        // 绑定dialog的确定按钮的监听事件
        $("#btnOk", window.top.document).click(function () {
            var bootstrapValidator = $("#processAidsForm", window.top.document).data('bootstrapValidator');
            bootstrapValidator.validate();
            if (bootstrapValidator.isValid()) {
                var url = $("#processAidsForm", window.top.document).attr('action');
                var myData = JSON.stringify({
                    "pMaterielCode": $("#pMaterielCode").val(),
                    "pMaterielName": $("#pMaterielName").val(),
                    "pTechnicalConditions": $("#pTechnicalConditions").val(),
                    "pMeasuringUnit": $("#pMeasuringUnit").val(),
                    "pMaterielPurpose": $("#pMaterielPurpose").val(),
                    "pDosageBicycle": $("#pDosageBicycle").val(),
                    "pNote": $("#pNote").val(),
                });
                $.ajax({
                    contentType:
                        "application/json",
                    type:
                        'POST',
                    url: url,
                    data: myData,
                    success:
                        function (result) {
                            // $('.modal-dialog', window.top.document).parent('div').remove()
                            // $('body', window.top.document).find('.modal-backdrop').remove();
                            // jquery 调用刷新当前操作的table页面的refresh方法
                            // $(window.parent.document).contents().find(".tab-pane.fade.active.in iframe")[0].contentWindow.doQuery();
                            activeTabBodyRefresh();
                            // if (result)
                            //     window.Ewin.alert({message: '添加数据成功!'});
                            // else
                            //     window.Ewin.alert({message: '添加数据失败!'});
                            if (result.success) {
                                layer.msg('添加成功', {icon: 1, time: 2000})
                            }
                            else if(!result.success){
                                window.Ewin.alert({message: result.errMsg})
                            }
                        },
                    error: function (status) {
                        window.Ewin.alert({message: status.status + ':添加数据失败!'});
                    }
                });
            }
        });
    })
    $(document).keydown(function(event) {
        if (event.keyCode == 13) {
            $('form').each(function() {
                event.preventDefault();
            });
        }
    });
    ]]>
</script>
<script th:src="@{/layer/layer.js}"></script>
</body>
</html>